package com.uniandes.edu.co.interfaz.ciclo;
import java.awt.Dimension;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JScrollPane;
import javax.swing.JTree;
import javax.swing.SwingConstants;

import javax.swing.WindowConstants;
import javax.swing.border.BevelBorder;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.DefaultTreeModel;
import javax.swing.SwingUtilities;

import com.uniandes.edu.co.controlador.ControladorCiclo;
import com.uniandes.edu.co.dto.Tsp;
import com.uniandes.edu.co.interfaz.mundo.Principal;
import com.uniandes.edu.co.interfaz.soporte.InterfazReporte;




/**
 * This code was edited or generated using CloudGarden's Jigloo
 * SWT/Swing GUI Builder, which is free for non-commercial
 * use. If Jigloo is being used commercially (ie, by a corporation,
 * company or business for any purpose whatever) then you
 * should purchase a license for each developer using Jigloo.
 * Please visit www.cloudgarden.com for details.
 * Use of Jigloo implies acceptance of these licensing terms.
 * A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
 * THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
 * LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
 */
@SuppressWarnings("serial")
//public class InterfazMostrarCiclo extends javax.swing.JFrame {
public class InterfazMostrarCiclo extends JDialog {
	
	private Principal principal;
	
	private JLabel jLabel1;
	private JScrollPane jScrollPane1;
	private JButton jButton1;
	private JButton jButton5;
	private JButton jButton4;
	private JButton jButton3;
	private JButton jButton2;
	private JTree jTree1;

	/**
	 * Auto-generated main method to display this JFrame
	 */
	/*public static void main(String[] args) {
		SwingUtilities.invokeLater(new Runnable() {
			public void run() {
				InterfazMostrarCiclo inst = new InterfazMostrarCiclo();
				inst.setLocationRelativeTo(null);
				inst.setVisible(true);
			}
		});
	}

	public InterfazMostrarCiclo() {
		super();
		initGUI();
	}*/
	
	public InterfazMostrarCiclo(Principal id) {
		super(id, true);
	    principal = id;
	    setTitle( "Menu Persona" );
	    initGUI();
	}

	private void initGUI() {
		try {
			setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
			getContentPane().setLayout(null);
			{
				jLabel1 = new JLabel();
				getContentPane().add(jLabel1);
				jLabel1.setText("Mostrar Ciclos");
				jLabel1.setHorizontalAlignment(SwingConstants.CENTER);
				jLabel1.setHorizontalTextPosition(SwingConstants.CENTER);
				jLabel1.setFont(new java.awt.Font("Segoe UI",1,14));
				jLabel1.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED));
				jLabel1.setBounds(37, 28, 425, 29);
			}
			{
				jScrollPane1 = new JScrollPane();
				getContentPane().add(jScrollPane1);
				jScrollPane1.setBounds(37, 77, 425, 227);
				{
					jTree1 = new JTree(Tsp.getSingleton().consultarTareasEnArbol());
					jScrollPane1.setViewportView(jTree1);
				}
			}
			{
				jButton1 = new JButton();
				getContentPane().add(jButton1);
				jButton1.setText("Visualizar Tarea");
				jButton1.setBounds(290, 315, 170, 23);
				jButton1.addActionListener(new ActionListener() {
					public void actionPerformed(ActionEvent evt) {
						dispose();
						InterfazConsultarTareaCiclo.main(null,false);
					}
				});
			}
			{
				jButton2 = new JButton();
				getContentPane().add(jButton2);
				jButton2.setText("Regresar");
				jButton2.setBounds(290, 381, 170, 23);
				jButton2.addActionListener(new ActionListener() {
					public void actionPerformed(ActionEvent evt) {
						dispose();
						//Principal.main(null);
					}
				});
			}
			{
				jButton3 = new JButton();
				getContentPane().add(jButton3);
				jButton3.setText("Reporte de avance");
				jButton3.setBounds(95, 316, 170, 23);
				jButton3.addActionListener(new ActionListener() {
					public void actionPerformed(ActionEvent evt) {
						dispose();
						InterfazReporte.mostrarPeporte(InterfazReporte.REPORTE_AVANCE);
					}
				});
			}
			{
				jButton4 = new JButton();
				getContentPane().add(jButton4);
				jButton4.setText("Reporte de calidad");
				jButton4.setBounds(95, 344, 170, 23);
				jButton4.addActionListener(new ActionListener() {
					public void actionPerformed(ActionEvent evt) {
						dispose();
						InterfazReporte.mostrarPeporte("Calidad");
					}
				});
			}
			{
				jButton5 = new JButton();
				getContentPane().add(jButton5);
				jButton5.setText("Reporte de personas");
				jButton5.setBounds(290, 349, 170, 23);
				jButton5.addActionListener(new ActionListener() {
					public void actionPerformed(ActionEvent evt) {
						String persona=JOptionPane.showInputDialog("Digite el Id de la persona");
						dispose();
						InterfazReporte.mostrarPeporte("persona "+persona);
					}
				});
			}
			pack();
			this.setSize(523, 460);
			centrarVentana();
		} catch (Exception e) {
			//add your error handling code here
			e.printStackTrace();
		}
	}
	
    private void centrarVentana(){
        Dimension dPantalla = Toolkit.getDefaultToolkit( ).getScreenSize( );
        Dimension dVentana = getSize( );

        int xEsquina = ( dPantalla.width / 2 ) - ( dVentana.width / 2 );
        int yEsquina = ( dPantalla.height / 2 ) - ( dVentana.height / 2 );

        setLocation( xEsquina, yEsquina );
    }

}
